package my.sc.factory;

import entity.Product;
import feign.hystrix.FallbackFactory;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import my.sc.openfeign.ProductFeign;
import org.springframework.stereotype.Component;

/**
 * @author ：Q大侠
 * @date ：Created in 2022/11/25 18:59
 * @description：Product工厂
 * @modified By：
 * @version:
 */
@Component
@Slf4j
public class ProductFeignFactory implements FallbackFactory<ProductFeign> {
    @Override
    public ProductFeign create(Throwable throwable) {
        return new ProductFeign() {
            @Override
            public Product getById(Long pid) {
                log.error("商品微服务故障"+throwable.getMessage());
                //返回默认商品对象
                Product product = new Product();
                return product;
            }
        };
    }
}
